unit WbExecutiveAutomationUnit;

{$WARN SYMBOL_PLATFORM OFF}

interface

uses
  ComObj, ActiveX, WbExecutive_TLB, StdVcl, WbExecutiveFormUnit, Windows;

type
  TWbExecutiveClass = class(TAutoObject, IWbExecutiveClass)
  protected
    function Get_dd: IDispatch; safecall;
    procedure Set_dd(const Value: IDispatch); safecall;
  private
    FROTCookie: Longint;
  public
    procedure Initialize; override;
    destructor Destroy; override;
  end;

implementation

uses ComServ;

procedure DisplayMessage(Text: String; title: String);
begin
  MessageBox(0, PChar(Text), PChar(title), MB_ICONEXCLAMATION);
end;

procedure TWbExecutiveClass.Initialize;
begin
  inherited;
  //Register object in ROT
  OleCheck(RegisterActiveObject(Self, CLASS_WbExecutiveClass, ActiveObject_Weak, FROTCookie))
end;

destructor TWbExecutiveClass.Destroy;
begin
  //Remove object from ROT
  OleCheck(RevokeActiveObject(FROTCookie, nil));
  inherited;
end;

function TWbExecutiveClass.Get_dd: IDispatch;
begin
Result := INodeArray[INodeArrayCount-1].dd;
WbExecutiveForm.Timer1.Enabled := true;
end;

procedure TWbExecutiveClass.Set_dd(const Value: IDispatch);
begin
//DisplayMessage('TWbExecutiveClass.Set_dd','');
WbExecutiveForm.Timer1.Enabled := true;
end;

initialization
  TAutoObjectFactory.Create(ComServer, TWbExecutiveClass, Class_WbExecutiveClass,
    ciMultiInstance, tmApartment);
end.
